﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace QuanLyCongDan.UniConverter
{
    public class TextCodeConverter
    {
        public static string VNI2Unicode(string input)
        {
            string result = string.Empty;
            for (int i = 0; i < input.Length; i++)
            {
                if (Convert.ToUInt16(input[i]) < 65)
                    result += input[i].ToString();
                else
                {
                    int index = VNI.find(Convert.ToUInt16(input[i]));
                    if (index != -1)
                    {
                        result += Unicode.result(index);
                    }
                    else
                    {
                        index = VNI.find(Convert.ToUInt16(input[i] * 16 * 16 + input[i - 1]));
                        if (index != -1)
                        {
                            result = result.Substring(0, result.Length - 1);
                            result += Unicode.result(index);
                        }
                    }
                }
            }
            return result;
        }
    }
}
